<template>
	<view class="mord">
		<view class="top" style="position: sticky;top: 44px;">
			<view :class="active == 0?'active':''" @click="changeActive(0)">
				待评价
			</view>
			<view :class="active == 1?'active':''" @click="changeActive(1)">
				已评价
			</view>

		</view>
		<view class="list" v-if="active == 0">
			<view class="li" v-for='l in data' :key="l.id">
				<view class="" v-for='la in l.oOrderDetails' :key="la.id" @click="toDetail(la)">
					<view class="imgbox">
						<image :src="la.DefaultImage" mode="widthFix"></image>
					</view>
					<view class="text">
						<view class="h1">
							{{la.cProductName}}
						</view>
						<view class="p">
							{{la.cProductClassName}}
						</view>

					</view>
				</view>

				<view class="">
					<view class="p">
						<!-- 评价可得50币 -->
						<navigator @click='bach(l.cOrderNo,l.iShopId)'>发表评价</navigator>
						<view class="both"></view>
					</view>
				</view>
			</view>
		</view>
		<view class="listB" v-if="active == 1">
			<view class="li" v-for="(l,ind) in list" :key="ind" @click="toDetail(l)">
				<view class="listTop">
					<view class="h">
						<image :src="l.cPortrait||'../../static/img/3/3-107.png'" mode="scaleToFill"></image>
						<view class="name">
							{{l.cMemberName}}
						</view>

					</view>
					<view class="text">
						<view class="time">
							{{l.dTime}}
						</view>
						{{l.cComment}}
					</view>
					<view class="imageBox" v-if="l.commentPics">
						<image :src="i" mode="aspectFit" v-for="(i,index) in getarry(l.commentPics)" :key="index">
						</image>
					</view>
				</view>
				<view class="listMain">
					<view class="imgbox">
						<image :src="l.cProductDefaultImg" mode="widthFix"></image>
					</view>
					<view class="imgMain">
						<view class="h1">
							{{l.cProductName}}
						</view>
						<view class="p">
							<text class="money">
								<text>¥</text>{{l.price}}
							</text>
							销量:{{l.iSales}}{{l.unit_name}}
						</view>
						<view class="button">
							<view>
								<image src="../../static/img/2/2-28.png" mode="widthFix"></image>
							</view>
							<view>
								<image src="../../static/img/2/2-13.png" mode="widthFix"></image>
							</view>
							<view>
								<image src="../../static/img/2/2-19.png" mode="widthFix"></image>
							</view>
						</view>
					</view>
					<view class="both"></view>
				</view>
				<!-- <view class="listCos">
					<view class="left">
						<image src="../../static/img/6/6-7.png" mode="widthFix"></image>
						<text>8</text>
						<image src="../../static/img/6/6-8.png" mode="widthFix"></image>
						<text>8</text>
						<text>1月前</text>
					</view>
					<view class="right">
						<image src="../../static/img/3/3-87.png" mode="widthFix"></image>
						<text>写追评</text>
					</view>
				</view> -->
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		name: "",
		components: {

		},
		data() {
			return {
				num: 0,
				data: [],
				active: 0,
				listB: [],
				pageIndex: 1,
				list: []
			}
		},
		onLoad(options) {
			var that = this;
			that.oder();

		},
		onReachBottom() {
			if (this.active == 1) {
				this.getList()
			} else {
				this.oder()
			}

		},
		methods: {

			oder() {
				let that = this;
				let status = "UNREMARK"
				if (this.active == 0) {
					status = "UNREMARK"
				} else {
					status = "REMARK"
				}
				that.$Request.post(
					that.$api.httpApi.user.oder + '&token=' + that.$SysCache.get('token'), {
						'onLineOffLine': 0,
						'orderType': 2,
						status: status,
						pageSize: 15,
						pageIndex: this.pageIndex
					}
				).then(res => {
					if (res.code == 200) {
						that.data = that.data.concat(res.data.orders);
						this.pageIndex++
						if (res.data.orders.length == 0) {
							uni.showToast({
								title: "没有更多了！",
								icon: "none"
							})
						}
					}
				});
			},
			changeActive(str) {
				this.active = str
				this.pageIndex = 1
				this.data = []
				if (str == 1) {
					this.getList()
				} else {
					this.oder('UNREMARK');
				}
			},
			bach(cOrderNo, iShopId) {

				uni.navigateTo({
					url: '/pages/user/orderPing?cOrderNo=' + cOrderNo + "&iShopId=" + iShopId
				})
			},
			getList() {
				this.$Request.post(
					this.$api.httpApi.goods.Comments + '&token=' + this.$SysCache.get('token'), {
						pageSize: 15,
						pageIndex: this.pageIndex,
						type: 2,
						isFront: true
					}
				).then(res => {
					if (res.code == 200) {
						res.data.models.forEach(item => {
							console.log(this.getDetail(item))
							this.getDetail(item)
							
						})


						this.list = this.list.concat(res.data.models);
						this.pageIndex++
						if (res.data.models.length == 0) {
							uni.showToast({
								title: "没有更多了！",
								icon: "none"
							})
						}
					}
				});
			},
			 getDetail(item) {
				 this.$Request.get(this.$api.httpApi.goods.iteminfo + '&id=' + item.iProduct_Id + '&token=' + this.$SysCache.get(
					'token') + '&iShopId=' + item.iShopId).then(
					res => {
						if (res.code == 200) {
							this.$set(item, 'price',res.data.fSalePrice)
							this.$set(item, 'iSales',res.data.iSales)
							this.$set(item, 'unit_name',res.data.unit_name)
							
						}
					})
			},
			getarry(arr) {
				return arr.split(";") || []
			},
			toDetail(item) {
				uni.navigateTo({
					url: `/pages/detail/index?id=${item.iProduct_Id||item.iProductId}&iShopId=${item.iShopId}`
				})
			}
		},
		onNavigationBarButtonTap() {
			// uni.navigateTo({
			//     // url: '/pages/user/vipjs'
			// })
		}


	}
</script>

<style scoped lang="less">
	.both {
		display: block;
		clear: both;
	}

	.list {
		.text {
			width: calc(100% - 225rpx - 25rpx);
			display: inline-block;
			vertical-align: middle;
			font-size: 26rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(77, 77, 77, 1);
		}
	}


	.p {
		font-size: 24rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: rgba(136, 136, 136, 1);
		margin-top: 18rpx;
		line-height: 41rpx;
	}

	.p text {
		font-size: 30rpx;
		margin-right: 12rpx;
	}

	.p navigator {
		display: inline-block;
		float: right;
		width: 122rpx;
		height: 41rpx;
		background: rgba(240, 64, 111, 1);
		border-radius: 21rpx;
		font-size: 19rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: rgba(255, 255, 255, 1);
		line-height: 41rpx;
		text-align: center;
	}

	.nav {
		margin-top: 18rpx;
	}

	.nav navigator {
		display: inline-block;
		width: 97rpx;
		height: 45rpx;
		background: rgba(255, 255, 255, 1);
		border: 1px solid rgba(240, 64, 111, 1);
		color: rgba(240, 64, 111, 1);
		text-align: center;
		font-size: 22rpx;
		line-height: 45rpx;
		border-radius: 23rpx;
	}

	.nav .add {
		display: inline-block;
		float: right;
		width: 33rpx;
		margin-top: 10rpx;
	}

	.nav .add image {
		display: block;
		width: 100%;

	}

	.list {
		width: 90%;
		margin: auto;
		padding-top: 30rpx
	}

	.list .li {
		background: #fff;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.listB .li {
		background: #fff;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.imgbox {
		width: 225rpx;
		display: inline-block;
		vertical-align: middle;
		margin-right: 25rpx;
		border-right: 1px solid #EFEFEF;
	}

	.imgbox image {
		width: 180upx;
	}

	.top {
		height: 62rpx;
		background: #040000;
		font-size: 26rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: rgba(231, 231, 231, 1);
		text-align: center;
		display: flex;
		line-height: 62rpx;
		width: 100%;
		justify-content: space-around;
		z-index: 1000;
	}

	.top navigator {
		flex: 1;
		margin-left: 90rpx;
		margin-right: 90rpx;
	}

	.active {
		border-bottom: 3rpx solid #F0406F;
		color: #F0406F;
	}

	uni-page-body {
		height: 100%;
	}

	.mord {
		min-height: 100%;
		background: #EEEEEE;
	}

	.listB {
		background: #eee;
		margin-bottom: 10rpx;

		.listCos {
			height: 68rpx;
			line-height: 68rpx;
			padding-left: 42rpx;
			padding-right: 42rpx;
		}

		.listCos .left {
			font-size: 22rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(181, 181, 181, 1);
			float: left;
		}

		.listCos .left image {
			display: inline-block;
			vertical-align: middle;
			margin-right: 10rpx;
			width: 32rpx;
		}

		.listCos .left text {
			display: inline-block;
			vertical-align: middle;
			margin-right: 56rpx;
		}

		.listCos .right {
			width: 99rpx;
			height: 41rpx;
			border: 1px solid rgba(240, 64, 111, 1);
			border-radius: 21rpx;
			float: right;
			margin-top: 15rpx;
			text-align: center;
			line-height: 30rpx;
			font-size: 23rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(240, 64, 111, 1);
		}

		.listCos .right image {
			display: inline-block;
			vertical-align: middle;
			width: 20rpx;
		}

		.listCos .right text {
			display: inline-block;
			vertical-align: middle;
		}

		.button {
			margin-top: 15rpx;

		}

		.button view {
			display: inline-block;
			vertical-align: middle;
			margin-right: 32rpx;
		}

		.button view image {
			display: inline-block;
			width: 28rpx;
		}

		.both {
			display: block;
			clear: both;
		}

		.listMain {
			border-bottom: 1px solid #efefef;
			display: flex;
		}

		.imgbox {
			width: 252rpx;
			border-right: 1px solid #efefef;
			// padding: 35rpx;
			float: left;
			height: 200upx;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.imgbox image {
			display: block;
			width: 160upx;
		}

		.imgMain {
			float: left;
			width: 467rpx;
			// padding: 65rpx;
			padding-bottom: 0;
			height: 200upx;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
		}

		.imgMain .h1 {
			font-size: 28rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(4, 0, 0, 1);
		}

		.imgMain .p {
			font-size: 24rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(136, 136, 136, 1);
			margin-top: 10rpx;
		}

		.imgMain .p .money {
			font-size: 24rpx;
			font-family: Adobe Heiti Std;
			font-weight: normal;
			color: rgba(240, 64, 111, 1);
			margin-right: 10rpx;
		}

		.imgMain .p .money text {
			font-size: 18rpx;
		}

		.list {
			background: #fff;
			margin-bottom: 10rpx;
		}

		.listTop {
			padding: 45rpx;
			border-bottom: 1px solid #efefef;

			.imageBox {
				margin-top: 20upx;
				display: flex;
				justify-content: flex-start;
				flex-wrap: wrap;

				image {
					width: 200upx;
					height: 200upx;
					margin-bottom: 20upx;

				}
			}
		}

		.h image {
			display: inline-block;
			width: 69rpx;
			height: 69rpx;
			vertical-align: middle;
			border-radius: 50%;
		}

		.h .name {
			display: inline-block;
			vertical-align: middle;
			font-size: 28rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(51, 51, 51, 1);
			margin-left: 10rpx;
		}

		.h navigator {
			float: right;
		}

		.h navigator image {
			display: inline-block;
			width: 35rpx;
		}

		.text {
			margin-top: 36rpx;
			font-size: 26rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(51, 51, 51, 1);
			line-height: 31rpx;
		}

		.text .time {
			font-size: 24rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: rgba(153, 153, 153, 1);
			margin-bottom: 13rpx;
		}

	}
</style>
